package com.yc.cloud.admin.controller;

import com.yc.cloud.admin.vo.dashboard.*;
import com.yc.cloud.admin.service.DashboardService;
import com.yc.cloud.common.basic.api.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 仪表盘数据接口
 * </p>
 *
 * @author kinggu
 * @since 2025-07-30
 */
@RestController
@RequestMapping("/dashboard")
@Tag(name = "仪表盘数据接口")
public class DashboardController {

    @Resource
    private DashboardService dashboardService;

    @GetMapping("/alarm/efficiency")
    @Operation(summary = "获取告警处理效率数据")
    public ResponseResult<AlarmEfficiencyVO> getAlarmEfficiency() {
        return ResponseResult.success(dashboardService.getAlarmEfficiency());
    }

    @GetMapping("/alarm/realtime")
    @Operation(summary = "获取实时告警列表")
    public ResponseResult<List<RealtimeAlarmVO>> getRealtimeAlarms(
            @RequestParam(defaultValue = "10") Integer limit) {
        return ResponseResult.success(dashboardService.getRealtimeAlarms(limit));
    }

    @GetMapping("/alarm/trend")
    @Operation(summary = "获取告警趋势数据(24小时)")
    public ResponseResult<AlarmTrendVO> getAlarmTrend() {
        return ResponseResult.success(dashboardService.getAlarmTrend());
    }

    @GetMapping("/key-metrics")
    @Operation(summary = "获取关键数据统计")
    public ResponseResult<KeyMetricsVO> getKeyMetrics() {
        return ResponseResult.success(dashboardService.getKeyMetrics());
    }

    @GetMapping("/alarm/distribution")
    @Operation(summary = "获取告警类型分布")
    public ResponseResult<AlarmDistributionVO> getAlarmDistribution() {
        return ResponseResult.success(dashboardService.getAlarmDistribution());
    }

    @GetMapping("/summary")
    @Operation(summary = "获取仪表盘所有数据（一次性获取全部）")
    public ResponseResult<DashboardSummaryVO> getDashboardSummary() {
        return ResponseResult.success(dashboardService.getDashboardSummary());
    }
}